const mongoose = require('mongoose')

const Schema = mongoose.Schema
const Types = Schema.Types

const UnDownloadedBook = new Schema({
  id: Types.ObjectId,
  name: {
    type: Types.String,
    required: true,
    index: 1
  },
  author: {
    type: Types.String,
    required: true,
    index: 1
  },
  bookId: { // Book实体中的Id，用以在下载完书籍之后完善Book中的下载地址
    type: Types.String,
    required: true,
    index: 1
  },
  type: { // 第三方书源类型，用以定时任务执行下载时分辨书源类型
    type: Types.String,
    required: true,
    index: 1
  },
  createTime: {
    type: Types.Date,
    default: Date.now,
    index: 1
  },
  bookOptions: Types.Map
})

module.exports = mongoose.model('UnDownloadedBook', UnDownloadedBook)
